<?php
/*************************************************************************
Class Pick_Dao_NewsInfo
----------------------------------------------------------------
PICKCOCMS Project
Company: PICKCO  Co., Ltd  
Email: admin@pick.vn
Last updated: 02/10/2009
**************************************************************************/
class Pick_Dao_NewsInfo extends Pick_Core_ObjectInfo{
	
	var $urlAvatar 	= 'upload/images/news';	
	var $urlVideo 	= 'upload/video';

	function Pick_Dao_NewsInfo($arrayField = array()){
        parent::Pick_Core_ObjectInfo();
		$this->setArrayField($arrayField);
	}
	function getExtFile() {
		$str = substr($this->video,-3);
		return $str;
	}	
	function getUrlOptionModule($lang='vn', $module = '') {
		$url = "";
		if(URL_TYPE == 1) {			# Query string
			$url = "http://".DOMAIN.(FOLDER?"/".FOLDER:"")."/".SCRIPT."?op=newsdetail&nId=".$this->getField('id')."&slug=".$this->getField('slug')."&lang=$lang";		
			return $url;
		} elseif(URL_TYPE == 2) {	# SEO
			if(SUB_DOMAIN) 
				$url = "http://".DOMAIN.(FOLDER?"/".FOLDER:"")."/".$lang."/".($module?$module."/":'').$this->getField('slug').".html";
			else 
				$url = "http://".DOMAIN.(FOLDER?"/".FOLDER:"")."/".$lang."/".($module?$module."/":'').$this->getField('slug').".html";
			return $url;		
		} else return "";	
	}
	function deleteAvatar(){
		$ok1 = unlink(ROOT_PATH . $this->urlAvatar .'/avatar/'. $this->getField('avatar'));
		$ok2 = unlink(ROOT_PATH . $this->urlAvatar .'/big/'. $this->getField('avatar'));
		$ok3 = unlink(ROOT_PATH . $this->urlAvatar .'/medium/'. $this->getField('avatar'));
		$ok4 = unlink(ROOT_PATH . $this->urlAvatar .'/storage/'. $this->getField('avatar'));
		if(!$ok1 && !$ok2 && !$ok3 && !$ok4)
			return true;
		return false;
	}	
	function deleteVideo(){
		$ok1 = unlink(ROOT_PATH . $this->urlVideo .'/'. $this->getField('video'));
		if($ok1)
			return true;
		return false;
	}	
}	
?>